<?php

include_once ("../dao/loginDAO.php");

function authenticate($username, $password) {
    $result = getUser($username, $password);
    $num = ConnectionManager::getInstance()->getNumRows();
    if ($num > 0) {
        $userRow = ConnectionManager::getInstance()->fetchArray();
        if ($userRow['USER_PASSWORD'] == $password) {
            $_SESSION['user'] = $username;
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

?>
